package com.tallysystem.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tallysystem.dao.TallysDao;
import com.tallysystem.daoimpl.TallysDaoImpl;

@WebServlet("/dodeleteTallyServlet")
public class DoDeleteTallyServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int tid = Integer.parseInt(request.getParameter("tid"));
		
		TallysDao tallyDao = new TallysDaoImpl();
		
		int res = tallyDao.deletetallys(tid);	
		if (res >= 0) {
				response.sendRedirect("showTallys");
				System.out.println("删除成功");
		} else {
			response.sendRedirect("error.jsp");
			System.out.println("删除失败");
		}
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
